<?php 
include "includes/comunes.php";

//Sumo totales de creditos
$sql="select sum(Monto)*-1 as tot, Sucursal from Movimientos where TipoComprobante=2 and Fecha='".date("Y-m-d")."' group by Sucursal";
//$sql="select sum(Monto)*-1 as tot, Sucursal from Movimientos where TipoComprobante=2 and Fecha='2013-09-19' group by Sucursal";
$restipo= $consultar=  cons_ins($sql);
$tot=0;
$texto="Ctos Oto.al ".date("d/m/Y h:s:i").": ";
while (!$restipo->EOF):
$texto.= "Suc: ".trim($restipo->fields['Sucursal'])." Mto: $".trim($restipo->fields['tot'])." - ";
$tot+=$restipo->fields['tot'];
$restipo->MoveNext();
endwhile;

//Sumo totales de pago
$sql="select sum(Monto) as tot, Sucursal from Movimientos where TipoComprobante=3 and Fecha='".date("Y-m-d")."' group by Sucursal";
//$sql="select sum(Monto) as tot, Sucursal from Movimientos where TipoComprobante=3 and Fecha='2013-09-19' group by Sucursal";
$restipo= $consultar=  cons_ins($sql);
$totPag=0;
$textoPagos="Pgos. al ".date("d/m/Y h:s:i").": ";
while (!$restipo->EOF):
$textoPagos.= "Suc: ".trim($restipo->fields['Sucursal'])." Mto: $".trim($restipo->fields['tot'])." - ";
$totPag+=$restipo->fields['tot'];
$restipo->MoveNext();
endwhile;



if($tot>0){
	enviarSMSTotales($texto,'3624620961');
	enviarSMSTotales($texto,'3624691382');
	}
	
if($totPag>0)	{
enviarSMSTotales($textoPagos,'3624620961');
enviarSMSTotales($textoPagos,'3624691382');
}

echo $texto."<br>";
echo $textoPagos."<br>";

?>